<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"
	import="java.util.ArrayList,com.metagurukul.metagranth.vo.Question"%>


<html lang="en">
<%
	ArrayList<Question> questionsList=null;
String message=null;
int countClosed=-1;
%>

<%
	if (request.getAttribute("questionsList") == null && request.getAttribute("messageForNoQuestions")== null) {
		request.getRequestDispatcher("adminquestion.do").forward(request,
		response);
	} else if(request.getAttribute("questionsList") != null) {
		 questionsList=(ArrayList<Question>)request.getAttribute("questionsList");
		 countClosed=(Integer)request.getAttribute("countClosed");
		 }
	else {
		 message = (String)request.getAttribute("messageForNoQuestions");
		 countClosed=(Integer)request.getAttribute("countClosed");
	}
%>

<head>
<meta charset="utf-8" />
<title>Dashboard I Admin Panel</title>

<link rel="stylesheet" href="../css/layout.css" type="text/css"
	media="screen" />
<!--[if lt IE 9]>
	<link rel="stylesheet" href="css/ie.css" type="text/css" media="screen" />
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
<script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="../js/hideshow.js" type="text/javascript"></script>
<script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$(".tablesorter").tablesorter();
	});
	$(document).ready(function() {

		//When page loads...
		$(".tab_content").hide(); //Hide all content
		$("ul.tabs li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content

		//On Click Event
		$("ul.tabs li").click(function() {

			$("ul.tabs li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content

			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active ID content
			return false;
		});

	});
</script>
<script type="text/javascript">
	$(function() {
		$('.column').equalHeight();
	});
</script>

</head>


<body>


	<header id="header"> <hgroup>
	<h1 class="site_title">
		<a href="home.jsp">Website Admin</a>
	</h1>
	<h2 class="section_title">Dashboard</h2>
	<div class="btn_view_site">
		<a href="http://www.metacube.com">View Site</a>
	</div>
	</hgroup> </header>
	<!-- end of header bar -->
	<div class="breadcrumbs_container">
		<article class="breadcrumbs">
		<a href="home.jsp">Website Admin</a>
		<div class="breadcrumb_divider"></div>
		<a class="current">Dashboard</a></article>
	</div>
	
	<article class="stats_overview">
					<div class="overview_today">
					<%if(countClosed!=-1){ %>
						<p class="overview_day">Total Questions Closed</p>
						<p class="overview_count"><%= countClosed%></p>
						<%} %>
											
					</div>
					
					<div class="overview_previous">
					<%if(questionsList==null){ %>
						<p class="overview_day">Total Questions Open</p>
						<p class="overview_count">0</p>
					<%}else{ %>	
					<p class="overview_day">Total Questions Open</p>
						<p class="overview_count"><%=questionsList.size() %></p>
						<%} %>					
					</div>
				</article>
	<section id="main" class="column"> <article
		class="module width_3_quarter"> <header>
	<h3 class="tabs_involved">Content Manager</h3>
	<ul class="tabs">
		<li><a href="#tab1">Questions</a>
		</li>
		
	</ul>
	</header>

	<div class="tab_container">
		<div id="tab1" class="tab_content">
		<%if (questionsList != null) { %>
			<table class="tablesorter" cellspacing="0">
				<thead>
					<tr>
					
						<th>Question</th>
						<th>Title</th>
						<th>Asked On</th>
						<th>Actions</th>
					</tr>
					
				</thead>
				<tbody>

					<%
						
							for (Question question : questionsList) {
					%>
					<tr>

						<td><a href="adminquestiondisplay.do?qid=<%=question.getQuesId()%>" class="question-hyperlink"
							title="<%=question.getQuestion()%>"><%=question.getQuestion()%></a>
						</td>
						<td><%=question.getTitle() %></td>
						<td><%=question.getDateOfPost() %></td>
						<td><input type="image" src="../images/icn_edit.png"
							title="Edit"><input type="image"
							src="../images/icn_trash.png" title="Trash">
						</td>
					</tr>
					
					<%
						} %>
					</table>
						<% } 
					
			else{ %>
			<table>
			<tr>
			<td align="center"><font> <b><em>No More Questions To Approve!!</em></b></font></td>
			</tr> </table>
			<%} %>
		</div>
		<!-- end of #tab1 -->
	</div>
	<!-- end of .tab_container --> </article><!-- end of content manager article -->
	</section>
</body>
</html>
